<template>
  <div class="app">
    <router-view/>
    <van-nav-bar
    title="我的收货地址"
    left-text="返回"
    right-text="新增地址"
    left-arrow
    @click-left="$router.go(-1)"
    @click-right="$router.push('/newaddress')"
      />
      <div class="addlist" v-for="(item,index) in addresslist" :key="index">
        <div class="left">
            <p class="title"><span>{{item.address}}</span></p>
        <p class="people"><span>{{item.name}}</span>&nbsp;&nbsp;&nbsp;<span>{{item.phone}}</span></p>
        </div>
        <div class="right">
            <span @click="alter(item)">修改</span>
        </div>
      </div>
  </div>
</template>

<script>
 import {mapState} from 'vuex'
export default {
    computed:{
        ...mapState(['addresslist'])
    },
    methods:{
        alter(item){
            // console.log(item)
            this.$router.push({
                path:'/amend',
                query:{
                    "name":item.name,
                    "phone":item.phone,
                    "address":item.address,
                    "addressid":item.id
                }
            })
        }
    }
    
}
</script>

<style scoped>
.addlist {
    padding: 20px 12px 10px 30px;
    text-align: left;
    display: flex;
    justify-content: space-between;
}
.right {
    width: 60px;
}
.right>span{
    float: right;
    font-size: 14px;
    border:1px solid #999;
}
.addlist .title {
    font-weight: bold;
    font-size: 18px;
}
.addlist .people {
    margin-top: 10px;
    color: #999;
    font-size: 14px;
}
</style>